package web.controller.user;

import common.consts.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import service.RecommendRecruitmentService;
import service.ServiceResponse;
import web.Routes;
import web.controller.Base;
import web.security.Protection;

/**
 * Created by aceyin on 15/7/6.
 * 列出根据用户所在城市、行政区人工推荐的工作列表
 */
@RestController
@RequestMapping(Routes.User.RECOMMEND)
public class Recommend extends Base {

    private static final Logger LOGGER = LoggerFactory.getLogger(Recommend.class);

    @Autowired
    RecommendRecruitmentService recommendRecruitmentService;

    @Protection
    @RequestMapping(method = RequestMethod.GET, produces = ContentType.JSON)
    public ServiceResponse list(@RequestParam(value = "page", defaultValue = "1") int page,
                                @RequestParam(value = "rows", defaultValue = "20") int rows) {

        long userId = getUserIdFromAuthHeader();

        LOGGER.debug("Receiving recommend request: page={}, rows={} from user[{}]", page, rows, userId);
        // TODO:valide user id

        return recommendRecruitmentService.getAllRecommendRecruitmentViewWithDesc(page, rows);
    }
}
